home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun 1987 May & June
/
rerun-1987-05-06.d64
/
puzzler's choice
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
13KB
|
389 lines
10 rem - puzzler's choice for c=64
20 rem - daniel miller
30 rem - astoria, n.y. 11103
40 rem - 4/19/86
50 vo=54296:wv=54276:at=54277:hi=54273:lo=54272:mv=0:goto110
60 poke781,p/40:poke782,p-40*peek(781):poke783,0:sys65520:return
65 poke785,232:poke786,7:poke209,232:poke210,7:poke211,0:poke213,39
66 print" s&$[146][223]hd[146][193]$[146][160]d[146][194][160]":pokerl,peek(rl):rl=usr(rl):return
70 pokevo,15:pokewv,17:pokeat,15:pokehi,68:pokelo,149
80 fortm=1to100:next:pokewv,0
90 pokevo,15:pokewv,17:pokeat,15:pokehi,34:pokelo,75
100 fortm=1to100:next:pokewv,0:return
110 poke53280,2:poke53281,0:poke646,1
120 print"[147]":p=53:gosub60:print"puzzler's choice[146]":print
130 p=170:gosub60:print"select choice:":print
140 print" 1. alphabet puzzle":print" 2. juggernaut":
150 print" 3. checkers switch":print" 4. end program":print
160 printtab(15)" enter (1-4): ";:ct=fre(0)
170 getch$:ifch$<"1"orch$>"4"then170
180 printch$:on val(ch$)goto200,1420,2510,190
190 end
200 dima$(16),b$(16),lt$(16),lu$(16),a(16),d1$(4,4)
210 aa=0:l2=rnd(-ti):x1=16:goto1230
220 print"[147]":poke53281,11
230 p=54:gosub60:print"alphabet puzzle[146]":print:ct=fre(0)
240 rem - puzzle screen
250 p=120:gosub60:print"";
260 printtab(15)a$(1);"[145][145]"a$(2);"[145][145]"a$(3);"[145][145]"a$(4)
270 printtab(15)a$(5);"[145][145]"a$(6);"[145][145]"a$(7);"[145][145]"a$(8)
280 printtab(15)a$(9);"[145][145]"a$(10);"[145][145]"a$(11);"[145][145]"a$(12)
290 printtab(15)a$(13);"[145][145]"a$(14);"[145][145]"a$(15);"[145][145]"a$(16)
300 ifmv>0thengosub70
310 ifaa=0then330
320 onaa-1 goto610,750,820
330 p=686:gosub60:print" your goal in this puzzle is to"
340 print" rearrange the letters on the playing"
350 print" board into order to be displayed on"
360 print" the screen."
370 p=926:gosub60:print"[158]press <return> to continue[146]";
380 wait 198,1:get rt$
390 fory=17to24:poke781,y:sys59903:next
400 p=682:gosub60:print" there are more than ten trillion"
410 print" letter combinations.":print
420 print" press 'f7' to end the puzzle.":print
430 printtab(14)"happy puzzling !";
440 fortm=1to4000:nexttm
450 fory=17to24:poke781,y:sys59903:next
460 p=844:gosub60:print"[159]press <return> to scramble letters[146]";:poke198,0
470 wait 198,1:get rt$
480 rt$="":poke781,21:sys59903
490 rem - scramble letters on puzzle screen
500 forx=1to16:a(x)=0:nextx
510 forlt=1to16:lt$(lt)=mid$(d$,lt,1):nextlt
520 l1=1
530 forll=1to16
540 l2=int(16*rnd(1))+1
550 ifa(l2)>0then540
560 lu$(l1)=lt$(l2):a(l2)=l2:l1=l1+1:nextll
570 d$="":forx=1to16:d$=d$+lu$(x):nextx
580 forx=1to16:lt$(x)="":a(x)=0:nextx
590 aa=2:goto1240
600 rem - is arrangement possible ?
610 ct=0:z=1:fory=1to16
620 forx=zto15:ifmid$(d$,x+1,1)<lu$(z)thenct=ct+1
630 nextx:z=z+1:nexty
640 iflu$(2)="p"orlu$(4)="p"orlu$(5)="p"orlu$(7)="p"thenct=ct+1:goto660
650 iflu$(10)="p"orlu$(12)="p"orlu$(13)="p"orlu$(15)="p"thenct=ct+1
660 poke781,18:sys59903
670 rem - ct:even - yes; ct:odd - no
680 ifct/2=int(ct/2)then700
690 goto500
700 e$="":forx=1to16:e$=e$+lu$(x):nextx:rem - solution format
710 p=970:gosub60:print"[159]press <return> to begin[146]";
720 wait 198,1:get rt$
730 poke781,21:sys59903:poke781,24:sys59903:rt$=""
740 aa=3:goto1230
750 forx=1to16:iflu$(x)="p"thenlu$(x)="[158] [146][159]":goto770
760 nextx
770 p=270:gosub60:print"[159]solve[146]"
780 p=350:gosub60:printlu$(1);" ";lu$(2);" ";lu$(3);" ";lu$(4)
790 printtab(30);lu$(5);" ";lu$(6);" ";lu$(7);" ";lu$(8)
800 printtab(30);lu$(9);" ";lu$(10);" ";lu$(11);" ";lu$(12)
810 printtab(30);lu$(13);" ";lu$(14);" ";lu$(15);" ";lu$(16)
820 ifd$=e$then1100:rem - puzzle solved
830 forx=1to16:lt$(x)=mid$(d$,x,1):next x
840 x=1:forro=1to4:forcl=1to4:d1$(ro,cl)=mid$(d$,x,1):x=x+1:nextcl,ro
850 forro=1to4:forcl=1to4:ifd1$(ro,cl)="p" thenr1=ro:c1=cl
860 nextcl,ro:p=852:gosub60:print"press 'f7' to end"
870 p=696:gosub60:print"letter ?[159] [146]";:poke198,0
880 getlt$:iflt$=""then880
890 iflt$="[136]"then1210
900 iflt$<"a"orlt$>"o"thenlt$="":goto880
910 print"";lt$;
920 forro=1to4:forcl=1to4:ifd1$(ro,cl)=lt$then r2=ro:c2=cl
930 nextcl,ro
940 ifabs(r1-r2)=1 and abs(c1-c2)=1 then960
950 ifsqr((r1-r2)^2+(c1-c2)^2)=1 then990
960 forx=1to5:p=935:gosub60:print"invalid move[146]";:fortm=1to500:nexttm
970 poke781,23:sys59903:fortm=1to500:nexttm,x
980 p=705:gosub60:print" ";:goto870
990 forx=1to16:iflt$(x)=lt$thenx1=x
1000 nextx
1010 forx=1to16:iflt$(x)="p"thenx2=x
1020 nextx
1030 lt$(x1)="p":lt$(x2)=lt$
1040 d$="":forx=1to16:d$=d$+lt$(x):nextx
1050 p=705:gosub60:print" ";
1060 p=776:gosub60:print"[158]move # [146]";
1070 mv=mv+1:p=782:gosub60:print"[158]";str$(mv)"[146]";
1080 aa=4:goto1240
1090 rem - end puzzle
1100 p=808:gosub60:print"you've solved the puzzle![146]";
1110 forcl=lo to lo+24:pokecl,0:next
1120 pokelo+5,85:pokelo+6,85:pokelo+12,85:pokelo+13,85:pokelo+24,15
1130 pokelo+4,33:pokelo+11,17:rl=1190:gosub65
1140 forx=1to6:readh1,l1,h2,l2:pokelo,l1:pokelo+1,h1:pokelo+7,l2:pokelo+8,h2
1150 ifh1=50thenfortm=1to200:nexttm
1160 fortm=1to100:nexttm
1170 nextx
1180 forcl=lo to lo+24:pokecl,0:next
1190 data25,30,18,209,33,135,25,30,42,62,31,165,50,60,37,162,42,62,31,165
1200 data50,60,37,162
1210 p=927:gosub60:print"[159]thanks for playing. 'bye'.[146]";
1220 fortm=1to1500:nexttm:poke198,0:run
1230 d$="abcdefghijklmnop":rem - puzzle format
1240 forx=1to16:ifmid$(d$,x,1)="p" thenx1=x
1250 nextx:ifmv=0then1280
1260 forx=1to16:ifmid$(d$,x,1)=lt$ then a=asc(lt$)-64:a$=lt$:goto1300
1270 nextx
1280 forx=1to16:a$(x)=""
1290 a$=mid$(d$,x,1)
1300 b=(a$="a")+(a$="c")+(a$="f")+(a$="h")+(a$="i")+(a$="k")+(a$="n")
1305 b=-1320*(b=-1)-1350*(b=0)
1310 poke785,188:poke786,168:pokeb,peek(b):b=usr(0)
1320 a$(x)="[166][166][166][157][157][157][166][146]"+a$+"[166][157][157][157][166][166][166][146]":rem "[166]" is 'c= +' [chr$(166)]
1330 ifmv>0then1380
1340 nextx:goto1380
1350 a$(x)=" [157][157][157] [146]"+a$+" [157][157][157] [146]"
1360 ifmv>0then1380
1370 nextx
1380 a$(x1)="[158] [157][157][157] [157][157][157] [146]"
1390 ifaa=0then220
1400 goto230
1410 rem - juggernaut main loop
1420 dim lc%(10),ch$(10),sp(2),sp$(10):goto2400
1430 p=788:gosub60:print" [157]";:ct=fre(0):poke198,0
1440 getmv$:forx=1to11:ifmv$=mid$("[133][136]abcdefghi",x,1)then1460
1450 next:goto1440
1460 ifmv$="[136]"then1800
1470 if mv$<>"[133]"then1500
1480 sol=1:s=0:mv=0:sol$="beha":goto2420
1490 s=s+1:mv$=mid$(sol$,s,1)
1500 p=788:gosub60:print mv$
1510 if ch$(asc(mv$)-64)<>"x" and ch$(asc(mv$)-63)<>"x" then1530
1520 msg$="invalid move[146]":p1=855:gosub1860:goto1430
1530 for x=1 to 10:if ch$(x)="x" thenlc=x:ld=x+1:goto1550
1540 next
1550 sp(1)=asc(mv$)-64:sp(2)=asc(mv$)-63
1560 rem - move checkers
1570 for y=ly% to lz% step-1
1580 pokev+val(sp$(sp(2))),y:pokev+val(sp$(sp(1))),y:next
1590 if sp(1)>lc then1640
1600 for x=lx%(sp(2)) to lx%(ld)
1610 pokev+val(sp$(sp(2)))-1,x:next
1620 for x=lx%(sp(1)) to lx%(lc)
1630 pokev+val(sp$(sp(1)))-1,x:next:goto1680
1640 for x=lx%(sp(1)) to lx%(lc) step-1
1650 pokev+val(sp$(sp(1)))-1,x:next
1660 for x=lx%(sp(2)) to lx%(ld) step-1
1670 pokev+val(sp$(sp(2)))-1,x:next
1680 for y=lz% to ly%
1690 pokev+val(sp$(sp(2))),y:pokev+val(sp$(sp(1))),y:next
1700 rem - update arrays & move-ctr
1710 ch$(lc)=ch$(sp(1)):ch$(ld)=ch$(sp(2)):ch$(sp(1))="x":ch$(sp(2))="x"
1720 sp$(lc)=sp$(sp(1)):sp$(ld)=sp$(sp(2)):sp$(sp(1))="xx":sp$(sp(2))="xx"
1730 mv=mv+1:p=516:gosub60:print""right$(str$(mv),len(str$(mv))-1)"[146]";
1740 slv$="":for x=1 to 10:slv$=slv$+ch$(x):next
1750 if slv$=win$ then1780
1760 if sol=1 then1490
1770 goto1430
1780 if sol=1 then1800
1790 msg$="congratulations !![146]":p1=850:gosub1860
1800 poke781,21:sys59903:poke198,0:p=851:gosub60:print"try again [y/n]: ";
1810 get yn$:if yn$<>"y" and yn$<>"n" thenyn$="":goto1810
1820 print yn$:pokev+21,0
1830 if yn$="y" then run1420
1840 run
1850 rem - message rtn.
1860 p=p1+80:for x=1 to 5:gosub60:print msg$;:for tm=1 to 500:next tm
1870 poke781,23:sys59903:fortm=1to500:nexttm,x
1880 print"":return
1890 rem - set up screen
1900 p=95:gosub60:print"juggernaut[146]";
1910 p=402:gosub60:printl1$:p=p+40:gosub60:printl1$
1920 for x=1 to 3:gosub1930:next:goto1940
1930 printspc(2)l3$;spc(28)l3$:return
1940 p=p+1